package com.wushi.smartorm;

import java.lang.reflect.Proxy;

/**
 * Mapper代理类， 并提供工具
 * @program: smartorm
 * @description:
 * @author: Grant Wu
 * @create: 2020-05-19 22:13
 **/

public class OrmMapperProxyFactory<T> {

    /**
     * 根据Mapper class生成代理类
     *
     * @param mapperClass
     * @return
     */
    public T getMapper(Class<T> mapperClass) {
        ClassLoader classLoader = mapperClass.getClassLoader();
        Object proxy = Proxy.newProxyInstance(classLoader, new Class[]{mapperClass}, new OrmMapperHandler());
        return (T) proxy;
    }


}
